package com.bupt.liutong.admin.groupon.quartz;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.bupt.liutong.admin.groupon.dto.Website;
import com.bupt.liutong.util.DateUtils;

public class GrouponTask {

	private List<Website> websites = new ArrayList<Website>();

	public void execute() {
		Date batchTime = DateUtils.getCurDate();
		for (Website website : websites) {
			website.setBatchTime(batchTime);
			System.out.println("---------- start getting info from " + website.getGrouponApi() + " ----------");
			website.getHandler().execute(website);
			System.out.println("---------- end ----------");
		}
	}

	public static void main(String[] args) {
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
				new String[] {
						"D:\\javadev\\MyEclipse 6.6\\workspace\\groupon-info-download\\WebRoot\\WEB-INF\\spring\\spring-local.xml",
						"D:\\javadev\\MyEclipse 6.6\\workspace\\groupon-info-download\\WebRoot\\WEB-INF\\spring\\spring-admin.xml" });
		GrouponTask grouponTask = (GrouponTask) context.getBean("grouponTask");
		grouponTask.execute();
	}

	public void setWebsites(List<Website> websites) {
		this.websites = websites;
	}
}
